package com.hzlx.materials.service.impl;

import java.util.List;

import com.hzlx.MesMaterialBatchesDto;
import com.hzlx.mesMaterialBatches.domain.MesMaterialBatches;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.hzlx.materials.mapper.MesMaterialsMapper;
import com.hzlx.materials.domain.MesMaterials;
import com.hzlx.materials.service.IMesMaterialsService;

/**
 * MES物料详细信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-01
 */
@Service
public class MesMaterialsServiceImpl implements IMesMaterialsService 
{
    @Autowired
    private MesMaterialsMapper mesMaterialsMapper;
    @Resource
    private RedisTemplate<String, Object> redisTemplateObject;
    String KEY="material-service:materials";
    /**
     * 查询MES物料详细信息
     * 
     * @param materialId MES物料详细信息主键
     * @return MES物料详细信息
     */
    @Override
    public MesMaterials selectMesMaterialsByMaterialId(Long materialId)
    {
        return mesMaterialsMapper.selectMesMaterialsByMaterialId(materialId);
    }

    /**
     * 查询MES物料详细信息列表
     * 
     * @param mesMaterials MES物料详细信息
     * @return MES物料详细信息
     */
    @Override
    public List<MesMaterials> selectMesMaterialsList(MesMaterials mesMaterials)
    {
        List<MesMaterials> list = mesMaterialsMapper.selectMesMaterialsList(mesMaterials);
        redisTemplateObject.opsForValue().set(KEY,list);
        return list;
    }

    /**
     * 新增MES物料详细信息
     * 
     * @param mesMaterials MES物料详细信息
     * @return 结果
     */
    @Override
    public int insertMesMaterials(MesMaterials mesMaterials)
    {
        return mesMaterialsMapper.insertMesMaterials(mesMaterials);
    }

    /**
     * 修改MES物料详细信息
     * 
     * @param mesMaterials MES物料详细信息
     * @return 结果
     */
    @Override
    public int updateMesMaterials(MesMaterials mesMaterials)
    {
        return mesMaterialsMapper.updateMesMaterials(mesMaterials);
    }

    /**
     * 批量删除MES物料详细信息
     * 
     * @param materialIds 需要删除的MES物料详细信息主键
     * @return 结果
     */
    @Override
    public int deleteMesMaterialsByMaterialIds(Long[] materialIds)
    {
        return mesMaterialsMapper.deleteMesMaterialsByMaterialIds(materialIds);
    }

    /**
     * 删除MES物料详细信息信息
     * 
     * @param materialId MES物料详细信息主键
     * @return 结果
     */
    @Override
    public int deleteMesMaterialsByMaterialId(Long materialId)
    {
        return mesMaterialsMapper.deleteMesMaterialsByMaterialId(materialId);
    }

}
